home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
System
/
Bond FBA
/
Bond FBA.p
< prev
next >
Wrap
Text File
|
1996-05-04
|
2KB
|
88 lines
{$I-}
program FBATest;
uses
AppleEvents, CheapSound;
var
gDone: Boolean;
gMyErr: OSErr;
startTime: Longint;
function MyGotRequiredParams (theAppleEvent: AppleEvent): OSErr;
var
myErr: OSErr;
returnedType: DescType;
actualSize: Size;
begin
myErr := AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, returnedType, nil, 0, actualSize);
if myErr = errAEDescNotFound then
MyGotRequiredParams := noErr
else if myErr = noErr then
MyGotRequiredParams := errAEParamMissed;
end; {MyGotRequiredParams}
function MyHandleQuiteEvent (theAppleEvent, reply: AppleEvent;
handlerRefcon: LongInt): OSErr;
begin
gMyErr := MyGotRequiredParams(theAppleEvent);
{if gMyErr = noErr then}
{Quit regardless of errors.}
gDone := true;
MyHandleQuiteEvent := gMyErr;
end; {MyHandleQuiteEvent}
function MyHandleOpenAppEvent (theAppleEvent, reply: AppleEvent;
handlerRefcon: LongInt): OSErr;
begin
gMyErr := MyGotRequiredParams(theAppleEvent);
if gMyErr = noErr then
begin
end; {noErr}
MyHandleOpenAppEvent := gMyErr;
end; {MyHandleOpenAppEvent}
procedure GetEvents;
var
theEvent: EventRecord;
gotOne: Boolean;
lastTime: LongInt;
begin
lastTime := TickCount;
repeat
gotOne := WaitNextEvent(everyEvent, theEvent, 500, nil);
if gotOne then
if theEvent.what = kHighLevelEvent then
gMyErr := AEProcessAppleEvent(theEvent);
if TickCount > lastTime + 120 then {At least 2 seconds from start}
if not SoundPlaying then
gDone := true;
if TickCount > lastTime + 7200 then {Never stay more than 2 minutes}
gDone := true;
until gDone;
end; {GetEvents}
const
kStackSize = (24 * 1024); {Lets create a larger stack}
function LMGetCurStackBase: Ptr;
inline
$2EB8, $0908; { MOVE.l $0908,(SP) }
begin
InitGraf(@thePort); { Init Quickdraw Globals}
SetApplLimit(Ptr(Ord(LMGetCurStackBase) - kStackSize)); { Set the Stack Size default is to small}
MaxApplZone; { Expand the heap to its max}
MoreMasters; { Create master block}
gDone := false;
gMyErr := AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, @MyHandleOpenAppEvent, 0, false);
gMyErr := AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, @MyHandleQuiteEvent, 0, false);
PlayNamedSound('James Bond Theme');
startTime := TickCount;
GetEvents;
end. {FBATest}